pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let (src_num, src_base) = parse(num_str);
    let mut snlen = src_num.len();
    let mut snum = 0u32;
    for c in src_num.chars() {
        let bit: u32 = c.to_string().parse().unwrap();
        snum += bit*(src_base.pow(snlen as u32-1));
        snlen -= 1;
    }

    let mut cal_result = String::new();
    while snum > 0 {
        let mut last_bit = snum % to_base;
        if last_bit > 9 {
            last_bit = 'a' as u32 + last_bit - 10;
        } else {
            last_bit = '0' as u32 + last_bit;
        }
        snum /= to_base;
        cal_result.insert(0, last_bit as u8 as char);
    }
    cal_result
}

fn parse<'a>(num_str: &'a str) -> (&'a str, u32) {
    let parts: Vec<_> = num_str.split('(').collect();
    let base_str: Vec<&str> = parts[1].split(')').collect();
    (parts[0], base_str[0].parse().unwrap())
}